<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="/js/axios-1.10.0.js"></script>
</head>
<body>
    <h1>{{ $user->id }}</h1>
    <h1>{{ $user->name }}</h1>
    <h1>{{ $user->email }}</h1>

    <hr>
    <hr>
    <hr>
    <button onclick="doAjax()">ajax</button>
    <button onclick="doAjax2()">ajax2</button>

    <script>
        function doAjax() {
            axios.get('http://www.laravel71201.cm/api/test001', {
                headers: {
                    // 不行
                    // 'api_token': 'fi7CJhCktQhqjs84fMPVO31q8krnANjl5iR4Qi2Kqtzj8w842ZBClQo1DJ4mpL2W'
                    // 不行
                    // 'api_token': 'Bearer fi7CJhCktQhqjs84fMPVO31q8krnANjl5iR4Qi2Kqtzj8w842ZBClQo1DJ4mpL2W'
                    // 不行
                    // 'api-token': 'fi7CJhCktQhqjs84fMPVO31q8krnANjl5iR4Qi2Kqtzj8w842ZBClQo1DJ4mpL2W'
                    // 不行
                    // 'api-token': 'Bearer fi7CJhCktQhqjs84fMPVO31q8krnANjl5iR4Qi2Kqtzj8w842ZBClQo1DJ4mpL2W'
                    // 成功
                    'Authorization': 'Bearer fi7CJhCktQhqjs84fMPVO31q8krnANjl5iR4Qi2Kqtzj8w842ZBClQo1DJ4mpL2W'
                }
            })
                .then(response => {
                    console.log(response.data);
                })
                .catch (response => {
                    console.error(response);
                });
        }

        function doAjax2() {
            axios.get('http://www.laravel71201.cm/api/test002')
                .then(response => {
                    console.log(response.data);
                })
                .catch (response => {
                    console.error(response);
                });
        }
    </script>
</body>
</html>

